<template>
  <div class="wrap">
    <header>
      <div class="headertop">
        <div class="header-img">
          <v-back></v-back>
        </div>
        <h1>
          <v-title></v-title>
        </h1>
        <div class="topradius">
          <i class="iconfont icon-xiaochengxu-gengduo"></i>
          <i class="topborder"></i>
          <i class="iconfont icon-xiaochengxu-guanbi"></i>
        </div>
      </div>
      <div class="search">
        <label for="seach">
          <i class="iconfont icon-fangdajing"></i>
        </label>
        <input type="search" name="" id="seach" placeholder="按内容搜索" />
      </div>
    </header>
    <div class="content">
      <div>
        <div class="product">
          <h2>热门精选</h2>
          <div class="hot">
            <div
              @click="goCate(item.id)"
              v-for="item in secondcate"
              :key="item.id"
            >
              <img :src="item.img" alt="" />
              <p>{{ item.catename }}</p>
            </div>
          </div>
        </div>
      </div>
      <aside>
        <ul>
          <li
            @click="tabsecond(i)"
            v-for="(item, i) in catelist"
            :key="item.id"
          >
            {{ item.catename }}
          </li>
        </ul>
      </aside>
    </div>
  </div>
</template>

<script>
import { getcates } from "../request/api";
export default {
  data() {
    return {
      catelist: [],
      secondcate: [],
    };
  },
  methods: {
    tabsecond(i) {
      this.secondcate = this.catelist[i].children;
    },
    goCate(id) {
      this.$router.push("/catelist/" + id);
    },
  },
  mounted() {
    // 获取分类信息
    getcates().then((res) => {
      // console.log(res, "2222");
      if (res.data.code == 200) {
        this.catelist = res.data.list;
        this.secondcate = res.data.list[0].children;
      }
    });
  },
};
</script>

<style scoped>
.search {
  height: 1.04rem;
  padding: 0 0.2rem;
  background-image: linear-gradient(180deg, #ff6040 0%, #ff8a80 100%);
  box-shadow: 0 2px 6px 0 rgba(255, 149, 128, 0.5);
  position: relative;
}
.search input {
  width: 100%;
  height: 0.64rem;
  border: 1px solid #e6e6e6;
  border-radius: 3px;
  padding-left: 0.7rem;
  font-size: 0.44rem;
  margin-top: 0.2rem;
}
.search label i {
  font-size: 0.44rem;
}
.search label {
  position: absolute;
  top: 50%;
  margin-top: -0.22rem;
  left: 0.23rem;
}
.content {
  min-height: 100vh;
  display: flex;
  justify-content: space-between;
  background-color: #eeeeee;
  flex-wrap: wrap;
}
aside {
  width: 2.36rem;
  box-shadow: 0 5px 10px 0 rgba(51, 51, 51, 0.1);
  text-align: center;
  order: -1;
  background-color: #fff;
}
aside li {
  font-size: 0.28rem;
  line-height: 0.28rem;
  padding: 0.59rem 0 0;
}

.product {
  width: 4.64rem;
  height: 4.36rem;
  background-color: #fff;
  padding: 0.2rem;
  box-sizing: border-box;
  margin: 0.2rem 0.2rem 0;
}
.product h2 {
  font-size: 0.32rem;
  font-weight: bold;
  line-height: 0.32rem;
  margin-bottom: 0.18rem;
}
.hot img {
  width: 1.28rem;
  margin-bottom: 0.1rem;
}
.hot div {
  text-align: center;
  font-size: 0.24rem;
  margin-bottom: 0.1rem;
  margin-right: 0.2rem;
}
.hot div:nth-child(3) {
  margin-right: 0;
}
.hot {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
}
</style>
